﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace WorkItemAnalyser.Core.Assertions
{
    public abstract class AssertionBase : IAssertion
    {
        protected Collection<AssertionResult> results;

        public abstract IEnumerable<AssertionResult> Execute(IEnumerable<WorkItem> workItems);

        public void AddResult(string ruleName, bool success, string message)
        {
            if (results == null)
                throw new ArgumentException("The results collection must be intialised before calling AddResult");

            results.Add(new AssertionResult
                            {
                                IsValid = success,
                                Message = message,
                                RuleName = ruleName
                            });
        }
    }
}